<template>
  <div class="custom-select">
    <el-select 
      multiple 
      v-model="value" 
      :size="size"
      :style="{ width: width }"
      :placeholder="placeholder">
    <div class="flex-option">
      <el-option
        v-for="item in receiveList"
        :key="item.value"
        :label="item.label"
        :value="item.value"
        :disabled="item.disabled">
      </el-option>
    </div>
  </el-select>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        value: ''
      }
    },
    props: {
      receiveList: {
        //接受的数据为[{id:1,name:'张三',name_en:'zhangsan',...},...]格式
        type: Array,
        default: () => [],
      },
      width: {
        //传入宽度值为字符串形式，如'50%'
        type: String,
        default: "100%",
      },
      size: {
        type: String,
        default: "",
      },
      placeholder: {
        type: String,
        default: "请选择",
      },
    },
  }
</script>
<style lang="scss" scoped>
.custom-select {
  ::v-deep .el-select {
    height: 36px;
  }
  ::v-deep .el-select__tags {
    white-space: nowrap;
    flex-wrap: nowrap;
    overflow: hidden;
    padding-left: 4px;
  }
  ::v-deep .el-tag.el-tag--info {
    border: 0;
    margin: 0;
    padding: 0;
    background: transparent;
  }
  ::v-deep .el-tag.el-tag--info .el-select__tags-text {
    &::after {
      content: '、';
    }
  }
  ::v-deep .el-tag__close {
    display: none;
  }
}
.flex-option {
  padding: 12px;
  display: flex;
  align-items: center;
  grid-gap: 8px;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 436px;
  ::v-deep .el-select-dropdown__item {
    padding: 3px 6px;
    border-radius: 2px;
    border: 1px solid #d0d0d0;
    cursor: pointer;
    color: rgba(0, 0, 0, .85);
    display: flex;
    align-items: center;
    min-width: 34px;
    justify-content: center;
    &.selected {
      border: 1px solid #3070ff;
      color: #3070ff;
      font-weight: 400px;
      &::after {
        font-size: 0;
        content: none;
      }
    }
  }
}
</style>